<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/WEB-INF/jsp/new/importHead.jsp"%>
<%@ include file="/WEB-INF/jsp/new/importCommonCss.jsp"%>
</head>
<body class="met-navfixed">
	<%@ include file="/WEB-INF/jsp/new/importHeader.jsp"%>

	<!-- body Start -->
	<!--页面主体-->
	<div class="moreList">
		<div class="moreListLeft">
			<img src="${basePath}/image/icon.png" />
			<ul>
				<li class="moreListLeftItem <c:if test="${type eq 'platform'}">active ${type}</c:if>">
		        	<a href="${basePath }/platform">平台动态</a>
		        </li>
		        <li class="moreListLeftItem <c:if test="${type eq 'news'}">active ${type}</c:if>">
		        	<a href="${basePath }/news">信息发布</a>
		        </li>
		        <li class="moreListLeftItem <c:if test="${type eq 'authority'}">active ${type}</c:if>">
		        	<a href="${basePath }/authority">权威解读</a>
		        </li>
		        <li class="moreListLeftItem <c:if test="${type eq 'push'}">active ${type}</c:if>">
		        	<a href="${basePath }/push">项目推送</a>
		        </li>
			</ul>
		</div>
		<div class="moreListRight">
			<div class="moreListRightTop">
				<div class="moreListRightTopItem active">
					<div class="title">
						<div class="titleText currentColumnText"></div>
						<div class="tips">
							<span class="backToHome">首页</span>><span class="currentColumnText"></span>
						</div>
					</div>
					<ul class="content">
						<c:if test="${!empty page}">
							<c:forEach items="${page.records }" var="article">
								<fmt:formatDate value="${article.insertTime}" pattern="yyyy-MM-dd" var="insertTime" />
								<li class="contentItem">
									<img src="${basePath}/image/time.png" /> 
									<span class="time">${insertTime }</span>
									<i></i>
									<a href="${basePath}/article/detail/${article.seqId }?type=${type}">${article.title }</a>
								</li>
							</c:forEach>
						</c:if>
					</ul>
				</div>
			</div>
			<div class="moreListRightBottom" id="pagination">
			</div>
		</div>
	</div>
	<!-- body End -->
	
	<form style="display: none;" method="post" action="${basePath }/${type}" id="searchForm">
		<input type="hidden" name="pageNum" value="1" />
	</form>

	<%@ include file="/WEB-INF/jsp/new/importFooter.jsp"%>
	<%@ include file="/WEB-INF/jsp/new/importCommonJS.jsp"%>

	<script>
    $(function(){
    	var columnType = '${type}';
    	var $currentColumn = $(".moreListLeftItem." + columnType);
    	$(".currentColumnText").text($currentColumn.text());
    	$(".header").css("background", "url(image/dh_bg.png) 0 0 no-repeat");
    	showPage(${page.current},${page.pages});
    });
    
	var list = function(page){
		if(!page){
			page = 1;
		}
		
		document.getElementById("searchForm").pageNum.value = page;
		
		document.getElementById("searchForm").submit();
	};
    
    function showPage(current,pageSize,size){
		if(!size){
			size = 6;
		}
		pageSize = pageSize <= 0 ? 1 : pageSize;
		current = current < 1 ? 1 : (current > pageSize ? pageSize : current);
		
		var str = '<ul>';
		
		if(current <= 1){
			str += '<li title="第一页"><span>«</span></li>';
			str += '<li title="上一页"><span>‹</span></li>';
		}
		else{
			str += '<li title="第一页"><a href="javascript:list('+1+');">«</a></li>';
			str += '<li title="上一页"><a href="javascript:list('+(current - 1)+');">‹</a></li>';
		}
		
		var half = Math.floor(size / 2);
		var startIndex = 0;
		if(current <= half){
			startIndex = 0;
		}
		else if(current >= (pageSize - half)){
			startIndex = pageSize - size;
		}
		else{
			startIndex = current - half;
			if(size % 2 != 0){
				startIndex--;
			}
		}
		startIndex = startIndex < 0 ? 0 : startIndex;
		for(var i = startIndex;i < startIndex + (size < pageSize ? size : pageSize);i++){
			str += i + 1 == current ? '<li class="active"><span>' + (i + 1) + '</span></li>' : '<li><a href="javascript:list('+(i + 1)+');">' + ( i + 1 ) + '</a></li>';
		}
		
		if(current >= pageSize){
			str += '<li title="下一页"><span>›</span></li>';
			str += '<li title="最后一页"><span>»</span></li>';
		}
		else{
			str += '<li title="下一页"><a href="javascript:list('+(current + 1)+');">›</a></li>';
			str += '<li title="最后一页"><a href="javascript:list('+pageSize+');">»</a></li>';
		}
		
		str += '</ul><div class="clearfix"></div></div>';
		$("#pagination").html(str);
	}
	</script>
</body>
</html>